/**
 * Created by Administrator on 2017-11-25
 */
define(function (require, exports, module) {
    'use strict';

    //类型选择
    var type;
    var array = new Array();
    function seltype(id) {
        if(!($("#"+id).hasClass("hover"))){
            type = $("#"+id).siblings(".advise").html();
            array.push(type);
            $("#"+id).addClass("hover");
            $("#"+id).children().show();
            $(".comfirm").css("background-color","#2b93ee");
        }else{
            var content=$("#"+id).html();
            array.slice(content);
            $("#"+id).removeClass("hover");
            $("#"+id).children().hide();
        }
    }

    function submit() {
        var opinion =$("textarea").val();
        if(opinion==''){
            toast.show("请输入建议内容！！！");
        } else if(array==''){
            toast.show("请选择建议类型！！！");
        }
        else {
            $.ajax({
                type: "POST",
                url: "/mine/mineopinion",
                data: {
                    array: array,
                    userid: user.id,
                    opinion: opinion
                },
                dataType: "json",
                success: function (res) {
                    toast.show("提交成功！！！");
                    $.get('/scenicspot/sceniclist', function (res) {
                        seajs.use("/script/scenicspot/sceniclist", function (scenic) {
                            $("#scenicbody").html(new EJS({url: "/views/scenicspot/sceniclist.ejs"}).render({
                                datas: res.datas.rows1,
                                datas2: res.datas.rows2
                            }));
                            SCENIC = scenic;
                            SCENIC.chooseinit();
                        });
                    })
                }
            });

        }
        }



    return {
        seltype: seltype,
        submit: submit
    }
});